package com.menchao.carsales.controller;

import com.menchao.carsales.common.http.ResponseData;
import com.menchao.carsales.pojo.Customer;
import com.menchao.carsales.service.ICustomerService;
import com.menchao.carsales.vo.CustomerQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Porject: carsales
 * Date: 2021/7/28
 * Author: menchao
 * Description:
 */

@RestController
@RequestMapping("customer")
public class CustomerController {

    @Autowired
    private ICustomerService customerService;

    @RequestMapping(value = "add",method = RequestMethod.POST)
    public ResponseData addCustomer(@RequestBody Customer customer){

        System.out.println("customer add: " + customer.toString());
       return   customerService.addCustomer(customer);
    }

    @RequestMapping(value = "getList",method = RequestMethod.GET)
    public ResponseData getCustomerList(@RequestBody CustomerQuery customerQuery){

        System.out.println("customer getList: " + customerQuery.toString());
        return customerService.getList(customerQuery);
    }

    @RequestMapping(value = "update",method = RequestMethod.POST)
    public ResponseData updateCustomer(@RequestBody Customer customer){
        return customerService.updateCustomer(customer);
    }

    @RequestMapping(value = "delete",method = RequestMethod.POST)
    public ResponseData deleteCustomer(@RequestBody Customer customer){
        return customerService.deleteCustomer(customer);
    }



}
